package com.geek.javase.ch12.videodemo;

import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Arrays;

/*
 *@author wangpeng
 *2025/10/23 16:00
 *@description TODO
 */
public class FileWriterDemo {
    public static void main(String[] args) {
        try (
                FileWriter fw = new FileWriter("copyFile1.txt");
                //FileWriter fw = new FileWriter("fileDemo.txt",true);
        ) {
            fw.write("tomorrow will be better!");
            fw.write('\n');
            fw.write("这是追加的测试！");
            fw.write('\n');
            String str1 = "这是第二次追加的测试！";
            //fw.write(Arrays.toString(st1.getBytes()));
            fw.write(str1);
            System.out.println("写出完毕");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
